<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">

	<title>Anything Zoomer | Usage</title>

	<link href="http://fonts.googleapis.com/css?family=Merienda+One" rel="stylesheet">
	<link rel="stylesheet" href="demo/style.css">
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
	<script src="demo/page.js"></script>

	<!-- Syntax highlighting -->
	<script src="http://mottie.github.com/tablesorter/docs/js/chili/jquery.chili-2.2.js"></script>
	<script src="http://mottie.github.com/tablesorter/docs/js/chili/recipes.js"></script>
</head>

<body id="use">

<div id="main-content">

	<h1 id="top">AnythingZoomer<sup>2</sup></h1>

	<a href="https://github.com/CSS-Tricks/AnythingZoomer/zipball/master" id="dl">Download</a>

	<ul id="nav">
		<li><a href="index.html">Calendar</a></li>
		<li><a href="image.html">Image</a></li>
		<li><a href="swap.html">Swap</a></li>
		<li><a href="text.html">Text</a></li>
		<li><a href="double.html">Double</a></li>
		<li><a class="current" class="use" href="use.html">Usage</a></li>
		<li><a class="play" href="http://jsfiddle.net/Mottie/6sp2b/">Playground</a></li>
		<li><a class="issue" href="https://github.com/CSS-Tricks/AnythingZoomer/issues">Issues</a></li>
	</ul>

	<p class="sections">Sections: <a href="#basics">Basics</a> | <a href="#html">HTML</a> | <a href="#css">CSS</a> |
		<a href="#parameters">Parameters</a> | <a href="#methods">Methods</a> | <a href="#callbacks">Callbacks</a>

	<a id="to-top" href="#top" title="back to the top">^</a>

	<h2 id="basics">Basics</h2>

	<p>This is a jQuery plugin, so you'll need to load the jQuery library first, then the plugin file, then invoke the
		new function on the area you wish to have zooming. There is a specific HTML structure and some required CSS to have all this
		work correctly, so read on. The full list of parameters is also below.</p>

	<pre class="html">&lt;link rel="stylesheet" href="css/anythingzoomer.css"&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/jquery.anythingzoomer.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  $(function(){
    $(&quot;#zoom&quot;).anythingZoomer();
  });
&lt;/script&gt;
</pre>
<small>* The minimum supported jQuery version is 1.3.2.</small>

		<h2 id="html">The HTML</h2>

		<p>The only required HTML is the wrapper and the small area. The large area is required if you don't clone the small area.</p>

	<pre><code><span class="cc c-wrap"></span>&lt;div id=&quot;zoom&quot;&gt;
<span class="cc c-small"></span>  &lt;div class=&quot;small&quot;&gt;
<span class="cc c-small"></span>    &lt;img src=&quot;demo/rushmore_small.jpg&quot; alt=&quot;small rushmore&quot; /&gt;
<span class="cc c-small"></span>  &lt;/div&gt;
<span class="cc c-commt"></span>    <span class="c-commt2">&lt;-- the large content can be cloned from the small content --&gt;</span>
<span class="cc c-large"></span>   &lt;div class=&quot;large&quot;&gt;
<span class="cc c-large"></span>      &lt;img src=&quot;demo/rushmore.jpg&quot; alt=&quot;big rushmore&quot; /&gt;
<span class="cc c-large"></span>   &lt;/div&gt;
<span class="cc c-wrap"></span>&lt;/div&gt;</code></pre>

		<p>There are five parts to the actual zoomable area. The idea is to allow for a good amount of flexibility in customizing each part. This
			includes the "small" area having different content from the "large" zooming area.</p>

		<ul>
			<li><span class="cc c-wrap"></span>The Wrap (#zoom) - goes around everything.</li>
			<li><span class="cc c-ovrly"></span>Overlay (.az-overlay) - small image overlay; the "az-overlay" class is only applied when hovering.</li>
			<li><span class="cc c-small"></span>Small Area (.small) - the default viewable area, that you mouse over to zoom.</li>
			<li><span class="cc c-large"></span>Large (.large) - the content that is viewable through the zoomer.</li>
			<li><span class="cc c-zoom"></span>Zoom (.az-zoom) - the zooming box that follows the mouse around.</li>
		</ul>

		<p>This is the HTML after the plugin has been applied.</p>

	<pre><code><span class="cc c-wrap"></span>&lt;div id="zoom" class="az-wrap"&gt;
<span class="cc c-wrap"></span>  &lt;span class="az-wrap-inner"&gt;

<span class="cc c-small"></span>    &lt;div class="small az-small"&gt;
<span class="cc c-ovrly"></span>      &lt;div class="az-overly az-overlay"&gt;&lt;/div&gt;
<span class="cc c-small"></span>      &lt;span class="az-small-inner"&gt;
<span class="cc c-small"></span>        &lt;img src="demo/rushmore_small.jpg" alt="small rushmore"&gt;
<span class="cc c-small"></span>      &lt;/span&gt;
<span class="cc c-small"></span>    &lt;/div&gt;

<span class="cc c-zoom" ></span>    &lt;div class="az-zoom az-windowed"&gt;
<span class="cc c-large"></span>      &lt;div class="large az-large"&gt;
<span class="cc c-large"></span>        &lt;img src="demo/rushmore.jpg" alt="big rushmore"&gt;
<span class="cc c-large"></span>      &lt;/div&gt;
<span class="cc c-zoom" ></span>    &lt;/div&gt;

<span class="cc c-wrap"></span>  &lt;/span&gt;
<span class="cc c-wrap"></span>&lt;/div&gt;</code></pre>

		<h2 id="css">The CSS</h2>

		<p>The widths, heights, borders and things like that can be altered to your needs. The positioning, z-index, overflow, and top/left values should stay as it is here to function properly.</p>

		<h3>Image Demo CSS Example</h3>

		<pre class="css">.zoom      { width: 500px; }
.small img { width: 250px; height: 167px; }
.large img { width: 500px; height: 333px; background: white; }</pre>

		<h3>anythingzoomer.css</h3>

		<pre class="css">/* AnythingZoomer */
.az-wrap, .az-small, .az-large {
  position: relative;
}
.az-wrap-inner {
	display: block;
	margin: 0 auto; /* center small & large content */
}
/* This wraps the large image and hides it */
.az-zoom {
	background: #fff;
	border: #333 1px solid;
	position: absolute;
	top: 0;
	left: 0;
	width: 110px;
	height: 110px;
	overflow: hidden;
	z-index: 100;
	display: none;
	-moz-box-shadow: inset 0px 0px 4px #000;
	-webkit-box-shadow: inset 0px 0px 4px #000;
	box-shadow: inset 0px 0px 4px #000;
}
/* Class applied to az-mover when large image is windowed */
.az-windowed {
	overflow: hidden;
	position: absolute;
}
/* Class applied to az-mover when large image is fully shown */
.az-expanded {
	height: auto;
	width: auto;
	position: static;
	overflow: visible;
}

/* overlay small area */
.az-overlay {
	background-color: #000;
	opacity: 0.3;
	filter: alpha(opacity=30);
	z-index: 10;
}

/* fade out small content when hovering
.az-hovered > * {
	opacity: 0.5;
	filter: alpha(opacity=50);
}
*/

/* edit mode coordinate styling */
.az-coords {
	display: none; /* hidden when expanded */
}
.az-zoom .az-coords {
	display: block;
	position: absolute;
	top: 0;
	right: 0;
	background: #000;
	background: rgba(0,0,0,0.5);
	color: #fff;
}</pre>

		<h2 id="parameters">All Parameters</h2>

		<pre class="js">$(&quot;#zoom&quot;).anythingZoomer({
  // content areas
  smallArea   : 'small',    // class of small content area; the element with this class name must be inside of the wrapper
  largeArea   : 'large',    // class of large content area; this class must exist inside of the wrapper. When the clone option is true, it will add this automatically
  clone       : false,      // Make a clone of the small content area, use css to modify the style

  // appearance
  overlay     : false,      // set to true to apply overlay class "az-overlay"; false to not apply it
  speed       : 100,        // fade animation speed (in milliseconds)
  edge        : 30,         // How far outside the wrapped edges the mouse can go; previously called "expansionSize"
  offsetX     : 0,          // adjust the horizontal position of the large content inside the zoom window as desired
  offsetY     : 0,          // adjust the vertical position of the large content inside the zoom window as desired

  // functionality
  switchEvent : 'dblclick', // event that allows toggling between small and large elements - default is double click
  delay       : 0,          // time to delay before revealing the zoom window

  // edit mode
  edit        : false,      // add x,y coordinates into zoom window to make it easier to find coordinates

  // callbacks
  initialzied : function(event, zoomer){}, // AnythingZoomer done initializing
  zoom        : function(event, zoomer){}, // zoom window visible
  unzoom      : function(event, zoomer){}  // zoom window hidden

});</pre>

		<div class="info">

			<h4>smallArea</h4>
			<ul>
				<li>Class name given to the small content area.</li>
				<li>This element must be inside of the wrapper and should contain an image or whatever visible content the user hovers over.</li>
				<li>Default value is <code>'small'</code>.</li>
			</ul>

			<h4>largeArea</h4>
			<ul>
				<li>Class name given to the large content area.</li>
				<li>This element must be inside of the wrapper and should contain an image or whatever visible content that will be seen inside the zoom window.</li>
				<li>The large content is replaced by a clone of the small area when the clone option is true. The dimensions of the large content should be set in the css.</li>
				<li>Default value is <code>'large'</code>.</li>
			</ul>

			<h4>clone</h4>
			<ul>
				<li>Make a clone of the small content and add it to the large area.</li>
				<li>This option allows you to only need to add the content to the page once, if the only difference between the small and large content is the dimensions defined by the css.</li>
				<li>See the <a href="text.html">text demo</a> for an example of how this can be useful.</li>
				<li>Default value is <code>false</code>.</li>
			</ul>

			<h4>overlay</h4>
			<ul>
				<li>An overlay is automatically added over every small content area. When this option is true, the overlay element will get a class name of "az-overlay" added to it.</li>
				<li>The css definition for "az-overlay" is within the "anythingzoomer.css" file and can be used to darken the small content during hovering (see the <a href="image.html">image demo</a>). Alternatively, you can lighten the small area content (look in the anythingzoomer.css file for the commented out definition for ".az-hovered > *") by using the hover class name (not associated with this option).</li>
				<li>Default value is <code>false</code>.</li>
			</ul>

			<h4>speed</h4>
			<ul>
				<li>Change the animation speed (in milliseconds) of the zoom window fading in and out.</li>
				<li>Default value is <code>100</code>.</li>
			</ul>

			<h4>edge</h4>
			<ul>
				<li>This sets the number of pixels from the outside edge of the small content to maintain the zoom window. Or, said another way... when the mouse arrow is beyond the small content edge by this set number of pixel, the zoom window will fade out.</li>
				<li>The small content edge may vary slightly depending on the value of the content ratio between the small and large content. See a more detailed explanation in the <code>offsetX</code> section below.</li>
				<li>Default value is <code>30</code>.</li>
			</ul>

			<h4>offsetX &amp; offsetY</h4>
			<ul>
				<li>When using the <code>edit</code> option, you may sometimes notice that the top left corner of the image isn't at 0,0 and the bottom right corner doesn't match the small area dimensions like it should be. This is partially due to the jQuery offset not including borders, margins or padding. And partially due to the ratio between the small and large areas .</li>
				<li>Sometimes it isn't a big deal to be a few pixels off, but if you need to adjust it perfectly, use these options. To do this, enable the edit mode coordinates (set edit to true) then use these options to adjust the location of the large content within the zoom window to set the proper position.</li>
				<li>Default value is <code>0</code>.</li>
			</ul>

			<h4>switchEvent</h4>
			<ul>
				<li>This is the name of the event that allows toggling between the small and large content.</li>
				<li>Valid events include: "click", "dblclick", "mouseover", "mouseout", etc.</li>
				<li>Default value is <code>dblclick</code>.</li>
			</ul>

			<h4>delay</h4>
			<ul>
				<li>Time to delay (in milliseconds) before revealing the zoom window.</li>
				<li>This is useful if you don't want the zoom window to open when the user is quickly passing over the content.</li>
				<li>Default value is <code>0</code>.</li>
			</ul>

			<h4>edit</h4>
			<ul>
				<li>When true, this option will add x,y coordinates into zoom window to make it easier to find coordinates.</li>
				<li>This is useful if you plan on using external triggers to open a zoom window. See the <a href="#methods">Methods</a> section below.</li>
				<li>Default value is <code>false</code>.</li>
			</ul>

			<h4>initialized</h4>
			<ul>
				<li>This is an optional callback function which is executed after AnythingZoomer has completely set up.</li>
				<li>Add any custom function using the <code>event</code> or <code>zoomer</code> object as desired.</li>
				<li>For a list of <code>zoomer</code> arguments and functions, see the <a href="#arguments">callback arguments</a> section below.</li>
				<li>Default value is <code>undefined</code>.</li>
			</ul>

			<h4>zoom</h4>
			<ul>
				<li>This is an optional callback function which is executed after the AnythingZoomer zoom window becomes visible.</li>
				<li>Add any custom function using the <code>event</code> or <code>zoomer</code> object as desired.</li>
				<li>For a list of <code>zoomer</code> arguments and functions, see the <a href="#arguments">callback arguments</a> section below.</li>
				<li>Default value is <code>undefined</code>.</li>
			</ul>

			<h4>unzoom</h4>
			<ul>
				<li>This is an optional callback function which is executed after the AnythingZoomer zoom window has hidden.</li>
				<li>Add any custom function using the <code>event</code> or <code>zoomer</code> object as desired.</li>
				<li>For a list of <code>zoomer</code> arguments and functions, see the <a href="#arguments">callback arguments</a> section below.</li>
				<li>Default value is <code>undefined</code>.</li>
			</ul>

		</div>

		<h2 id="methods">Methods</h2>

		<h3>Enable or Disable AnythingZoomer</h3>
		<p>To enable or disable AnythingZoomer, call the plugin with the appropriate text:</p>

<pre class="js">$('.zoom').anythingZoomer('disable'); // disable AnythingZoomer
$('.zoom').anythingZoomer('enable');  // enable AnythingZoomer</pre>

		<p>This method is demonstrated in the <a href="double.html">Double</a> demo page. What isn't shown there is that when AnythingZoomer is disabled, the zoom window automatically closes and the small area content is shown.</p>

		<h3>Control Zoom Window Externally</h3>
		<p>You can open the zoom window using an external link using these methods. This would be useful to highlight portions of the content in say instructions on how to use an app or name the presidents in the image demo.</p>

<pre class="js">// TARGET X,Y COORDINATE
// $('.zoom').anythingZoomer( x, y, [ w, h ] );
// x, y = left and top coords to target (will be centered in the zoom window)
// w, h = width and height of the zoom window, if not defined, it will default to the css definition
// Example: $('.zoom').anythingZoomer( 88, 51, [200,200] );
// 88, 51 will target George Washington; [200,200] will make the zoom window 200px x 200px in size

$('.zoom').anythingZoomer( 88, 51, [200,200] );

// TARGET AN OBJECT
// $('.zoom').anythingZoomer( 'selector', [ xOffset, yOffset ], [zoomW, zoomH] );
// 'selector' - jQuery selector targeting the element
// [xOffset, yOffset] - by default the zoom window will center itself on the element, if you want to move the window, change the offset values (negative values are okay)
// [zoomW, zoomH] - width and height of the zoom window

// Example: $('.zoom').anythingZoomer( '.day[rel=2009-08-26]', [0, 0], [200, 200] );
// '.day[rel=2009-08-26]' targets the table cell with day class name and rel attribute of "2009-08-26"
// [ 0, 0 ]  has no x or y offset; this can be replaced with '' (empty string); or if only one number is included, like [-1] this sets the xOffset only
// [200,200] will make the zoom window 200px x 200px in size

$('.zoom').anythingZoomer( '.day[rel=2009-08-26]', [0, 0], [200, 200] );
</pre>

<h3>Image Demo Example</h3>
<pre class="html">&lt;a href=&quot;#&quot; class=&quot;president&quot; rel=&quot;88,51&quot;&gt;George Washington&lt;/a&gt;,
&lt;a href=&quot;#&quot; class=&quot;president&quot; rel=&quot;114,62&quot;&gt;Thomas Jefferson&lt;/a&gt;,
&lt;a href=&quot;#&quot; class=&quot;president&quot; rel=&quot;133,80&quot;&gt;Theodore Roosevelt&lt;/a&gt; or
&lt;a href=&quot;#&quot; class=&quot;president&quot; rel=&quot;160,78&quot;&gt;Abraham Lincoln&lt;/a&gt;</pre>

<pre class="js">$('.president')
  // prevent the link from doing anything
  .bind('click', function(){
    return false;
  })
  // click or mouseover the link to show the zoom window
  .bind('mouseover click', function(){
    // get coordinates from rel attribute
    var loc = $(this).attr('rel');
    if (loc && loc.indexOf(',') > 0) {
      loc = loc.split(',');
      // send the coordinates to anythingZoomer
      $('.zoom').anythingZoomer( loc[0], loc[1] );
    }
    return false;
  });</pre>

		<h2 id="callbacks">Callbacks and Events</h2>

		<p>These callbacks were added to allow further customizations.</p>

		<h3>Callback functions</h3>

<pre class="js">$('#zoom').anythingZoomer({
  // initialized occurs after AnythingZoomer has initialized
  initialized : function(e, zoomer){},
  // zoom occurs when the zoom window is visible
  zoom        : function(e, zoomer){},
  // unzoom occurs when the zoom window is hidden
  unzoom      : function(e, zoomer){}
});
</pre>

		<h3>Events</h3>

		<p>Bind to the AnythingZoomer's events as follows:</p>

<pre class="js">
$('#zoom').bind('initialized', function(e, zoomer){
  // do something after AnythingZoomer has initialized
});

$('#zoom').bind('zoom unzoom', function(e, zoomer){
  // do something when the zoom toggles
  if (e.type === "zoom") {
    // do something when zoomed
  } else {
    // do something when unzoomed
  }
});</pre>

		<h3 id="arguments">Callback and Events Arguments and Functions</h3>

		<p>These arguments and functions are available from the callback or event methods, or from the <code>zoomer</code> data object.
			<br>Access the AnythingZoomer object from outside of callbacks and events as follows:</p>

<pre class="js">var zoomer = $('#zoom').data('zoomer');</pre>

		<div class="info">

			<h4>zoomer.$wrap</h4>
			<ul>
				<li>jQuery object of the wrapper which contains both the large and small content.</li>
			</ul>

			<h4>zoomer.state</h4>
			<ul>
				<li>true when the small content is showing, false when large content is visible.</li>
			</ul>

			<h4>zoomer.current</h4>
			<ul>
				<li>This variable contains the current x and y position of the mouse within the small content area.</li>
				<li>The value is updated everytime the mouse is moved, so it can be monitored externally if desired.</li>
			</ul>

			<h4>zoomer.$inner</h4>
			<ul>
				<li>jQuery object of the span immediately inside of <code>zoomer.$wrap</code>.</li>
				<li>This is the element that centers the small and large content using css; look in <code>.az-wrap-inner</code>.</li>
			</ul>

			<h4>zoomer.$small</h4>
			<ul>
				<li>jQuery object of the small area.</li>
			</ul>

			<h4>zoomer.$large</h4>
			<ul>
				<li>jQuery object of the large area.</li>
			</ul>

			<h4>zoomer.$zoom</h4>
			<ul>
				<li>jQuery object of the zoom window which contains the large content area.</li>
				<li>This is the zoom window that follows the mouse and repositions the large area.</li>
			</ul>

			<h4>zoomer.$overlay</h4>
			<ul>
				<li>jQuery object of the overlay element which is contained within the small area and has the same dimensions.</li>
				<li>When the <code>overlay</code> option is true, this object gets the <code>az-overlay</code> class name applied to it.</li>
			</ul>

			<h4>zoomer.options.{name}</h4>
			<ul>
				<li>Access any of the zoomer options (e.g. <code>zoomer.options.edge</code>).</li>
				<li>Trying to set the options this way is possible, but may break the zoomer.</li>
			</ul>

			<h4>zoomer.setTarget('selector', [xOffset, yOffset], [zoomW, zoomH])</h4>
			<ul>
				<li>This function is called when controlling the zoom window externally.</li>
				<li>Call this function if you are using a jQuery selector to target an element; use <code>zoomer.zoomAt()</code> if you have specific coordinates to set.</li>
				<li>Please refer to the methods section for more details on how to set the parameters.</li>
			</ul>

			<h4>zoomer.zoomAt(x, y, [zoomW, zoomH])</h4>
			<ul>
				<li>This function is called by the <code>zoomer.setTarget()</code> function after it calculates the x and y coordinates.</li>
				<li>Call this function directly if you already know the coordinates.</li>
			</ul>

			<h4>zoomer.showSmall()</h4>
			<ul>
				<li>This function is called when switching from the large content to the small content.</li>
			</ul>

			<h4>zoomer.showLarge()</h4>
			<ul>
				<li>This function is called when switching from the small to large content.</li>
			</ul>

			<h4>zoomer.hideZoom()</h4>
			<ul>
				<li>This function is called when the zoom window needs to be hidden.</li>
				<li>The "unzoom" callback will not be triggered.</li>
			</ul>

			<h4>zoomer.setEnabled(boolean)</h4>
			<ul>
				<li>This function will enable (if boolean is true) or disable (if boolean is false) AnythingZoomer.</li>
				<li>When the plugin is disabled, any open zoom window will be closed and the large content will be hidden.</li>
				<li>This function is called directly from the shortcut method which allows you to call the plugin using 'enable' or 'disable'.</li>
			</ul>

		</div>

</div>

</body>

</html>